/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ftpcombiner.server.serverconnection;

import ftpcombiner.server.ServerConnection;
import it.sauronsoftware.ftp4j.FTPFile;
import java.util.Objects;

/**
 *
 * @author Ben
 */
public class ServerItem implements Comparable {
//
//    @Override
//    public boolean equals(Object obj) {
//        return obj instanceof ServerItem&&obj.toString().equals(toString());
//    }

    private FTPFile alias;
    private boolean editing = false;

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(this.name);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ServerItem other = (ServerItem) obj;
        if (!Objects.equals(this.name, other.name)) {
            return false;
        }
        return true;
    }
    private ServerConnection parentServer;
    protected String name;

    public ServerItem(ServerConnection parentServer, String name) {
        this.parentServer = parentServer;
        this.name = name;
        alias = new FTPFile();
    }

    public ServerItem(ServerConnection parentServer, FTPFile alias) {
        this.parentServer = parentServer;
        this.name = alias.getName();
        this.alias = alias;
    }

    public String getName() {
        return name;
    }

    public ServerConnection getServer() {
        return parentServer;
    }

    @Override
    public String toString() {
        return getName();
    }

    public FTPFile getAlias() {
        return alias;
    }

    public void setEditing(boolean editing) {
        this.editing=editing;
    }
    public boolean isEditing(){
        return editing;
    }

    @Override
    public int compareTo(Object o) {
        return getName().equals(o)?0:1;
    }

    
}
